Apache curator Getting Started combat
Curator is a zookeeper client for Netflix's open source, and curator has a higher level of abstraction compared to the native client provided by zookeeper, simplifying the development of zookeeper clients. 1.Zookeeper Installation Deployment
Zookeeper deployment is simple, if you already have a Java runtime environment, down
Service Discovery with Apache Curator, discoverycurator
Introduction to Curator
Curator is a client tool for Zookeeper (people who do not know about Zookeeper can access ZooKeeper). It encapsulates connection processing between ZooKeeper client and zookeeper server and common operations on Zookeeper, provides abstract encapsulation of ZooKeeper application scenar
Curator is a set of zookeeper client frameworks for Netflix open source. Netflix in the process of using zookeeper found that the zookeeper comes with a client too low, the application needs to handle a lot of things when it is used, so it is packaged on its basis and provides a better client framework. Netflix is in the process of using zookeeper, we have encountered the problem, so began to study, first from his on GitHub source code, wiki documents
ZooKeeper (3.4.5) uses Curator (2.7.0) to listen for events and zookeepercurator
The native API of ZooKeeper supports event listening by registering Watcher, but Watcher notifications are one-time. Therefore, it is cumbersome to register Watcher repeatedly during development. Curator introduces Cache to listen to events on the ZooKeeper server. The Cache encapsulates the ZooKeeper event listening and can au
Zookeeper is cumbersome for clients on Java, and watcher can only be triggered once. So with Zkclient and curator. The curator feature is that you can use the fluent style to write code. Today the curator API is a simple use of a bit. 1.curator operation of the node requires curato
Zookeeper native support through the registration of watcher to do event monitoring, but its use is not particularly convenient, the need for developers to repeatedly register their own watcher, more cumbersome. Curator introduces the cache to monitor the Zookeeper server events. Cache is the packaging of event listening in curator, and its monitoring of events can be approximated as a comparison between a
The curator framework is best used by the most popular zookeeper clients.
It has the following three advantages
1 A set of very friendly Operation API;
2. Provide some advanced features (including, but not limited to, the packaging mentioned in the previous article)
3. Easy to test
MAVEN relies on the following
[HTML] view plain copy print?
According to the official document and package structure, you can easily see the
It is said that curator connection mechanism is very good, so in the analysis of curator connection and retry mechanism, I would like to first understand the original zookeeper connection problems.Here is my review of the results of the summary, reproduced please specify the source: Jiq Technical BlogAlthough curator provides a so-called high-level abstraction AP
Reprint: http://www.mamicode.com/info-detail-494364.htmlLabel:Zookeeper native API support through the registration of Watcher for event monitoring, but watcher notification is a one-time, so the development process needs to be repeatedly registered watcher, more cumbersome. Curator introduced the cache to listen for events on the zookeeper server. The cache encapsulates zookeeper event monitoring, automates the process of repeatedly registering monit
The Zookeeper Crud API for the OST has synchronous and asynchronous points, and for asynchronous APIs, the AsyncCallback callback needs to be passed. For getdata,getchildren,exists These three APIs, you can also set watcher. How are these features implemented in curator?In curator, you can get results asynchronously in the following three ways:1.inBackground () +curatorlistener2.inBackground (New Background
Service Discovery
With the increasing popularity of micro-services, after the system split, the various service modules between the provider and consumer need to be able to find each other, we call service discovery.
In soa/distributed systems, services need to find each other. i.e. a Web service might need to find a caching service, etc. DNS can be used for this but it's nowhere near flexible enough for services, is constantly changing. A Service Discovery system provides a mechanism for:servi
Curator provides three types of caching methods: Path Cache,node cache and tree cache.Path Cachethe Path cache is used to monitor a znode child node . When a child node is added, updated, deleted, the Path cache changes its state, containing the latest child nodes, the data and state of the child nodes . That, as its name indicates, monitors the path.There are four classes involved in actual use:
Pathchildrencache
Pathchildrencacheevent
In practical application development, when a znode changes we need to be notified and do some follow-up processing, curator recipes provides the path Cache to help us easily implement watch Znode. Path Cache
The Path cache monitors changes to Znode sub-nodes, for example: Add,update,delete.
A Path Cache is used to watch a znode. Whenever a child is added, updated or removed, the Path Cache would change it state to contain the current set of children ,
Curator Framework client use, please see a blog "Zookeeper client curator framework use".
The Curatorframework class has an interface that determines whether a node exists checkexists (), which returns a Org.apache.zookeeper.data.Stat object that has a Ephemeralowner attribute in the object.
If the node is a persisted node, the value of Ephemeralowner is 0 if the node is a temporary node, the value of Ephem
implementation, that is, the first node is not, that no one acquires a lock, and then you create this node, you get this lock. Remember, this node must be a temporary node.Then, of course, acquiring the lock this operation is a dead loop. Controlled by a static variable Countdownlatch. If Countdownlatch is greater than 0, wait hangs, and when someone else releases, another loop continues, attempting to acquire the lock.Let's release the lock. This node is deleted. Countdownlatch Reset to 1.The
Curator solves many zookeeper client very low-level detail development work, including connection reconnection, repeated registration watcher and nodeexistsexception Anomaly, and so on, has become the Apache top project, is one of the most widely used zookeeper clients in the world, Patrick Hunt (the core submitter of zookeeper code) is a "guava is to Java what curator be to zookeeper" (
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.